﻿<UserControl x:Class="GitScc.UI.CommitDetails" xmlns:cmd="clr-namespace:GitUI" 
			 xmlns:avalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
			 xmlns:model="clr-namespace:GitScc.DataServices;assembly=GitApi" 
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 mc:Ignorable="d" 
			 d:DesignHeight="300" d:DesignWidth="800">
	<UserControl.Resources>
		<ControlTemplate x:Key="BackButtonControlTemplate" TargetType="{x:Type Button}">
			<Grid Width="24" Height="24">
				<VisualStateManager.VisualStateGroups>
					<VisualStateGroup x:Name="CommonStates">
						<VisualState x:Name="Normal"/>
						<VisualState x:Name="MouseOver">
							<Storyboard>
								<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse">
									<EasingColorKeyFrame KeyTime="0" Value="#FF99B6D1"/>
								</ColorAnimationUsingKeyFrames>
								<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlock">
									<EasingColorKeyFrame KeyTime="0" Value="White"/>
								</ColorAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="Pressed"/>
						<VisualState x:Name="Disabled"/>
					</VisualStateGroup>
				</VisualStateManager.VisualStateGroups>
				<Ellipse x:Name="ellipse" Fill="White" HorizontalAlignment="Stretch" Stroke="#FF99B6D1" Width="Auto" StrokeThickness="2"/>
				<TextBlock x:Name="textBlock" Margin="0,1,0,0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Foreground="#FF99B6D1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"><Span FontFamily="Wingdings 2" Language="en-us"><Run Text="Ó"/></Span></TextBlock>
			</Grid>
		</ControlTemplate>

		<Style TargetType="{x:Type ListBoxItem}">
			<Style.Triggers>
				<Trigger Property="ItemsControl.AlternationIndex" Value="1">
					<Setter Property="Background" Value="#FFDBDBDB"></Setter>
				</Trigger>
			</Style.Triggers>
		</Style>
		<ControlTemplate x:Key="btnSwitchControlTemplate" TargetType="{x:Type Button}">
			<Grid Width="24" Height="24">
				<VisualStateManager.VisualStateGroups>
					<VisualStateGroup x:Name="CommonStates">
						<VisualState x:Name="Normal"/>
						<VisualState x:Name="MouseOver">
							<Storyboard>
								<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse">
									<EasingColorKeyFrame KeyTime="0" Value="#FF99B6D1"/>
								</ColorAnimationUsingKeyFrames>
								<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlock">
									<EasingColorKeyFrame KeyTime="0" Value="White"/>
								</ColorAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="Pressed"/>
						<VisualState x:Name="Disabled"/>
					</VisualStateGroup>
				</VisualStateManager.VisualStateGroups>
				<Ellipse x:Name="ellipse" Fill="White" Stroke="#FF99B6D1" StrokeThickness="2"/>
				<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF99B6D1" FontWeight="Bold"><Span FontSize="17.3333333333333" FontFamily="Wingdings 3" Language="en-us"><Run Text="F"/></Span></TextBlock>
			</Grid>
		</ControlTemplate>
		<ControlTemplate x:Key="PatchButtonTemplate" TargetType="{x:Type Button}">
			<Grid Width="24" Height="24">
				<VisualStateManager.VisualStateGroups>
					<VisualStateGroup x:Name="CommonStates">
						<VisualState x:Name="Normal"/>
						<VisualState x:Name="MouseOver">
							<Storyboard>
								<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse">
									<EasingColorKeyFrame KeyTime="0" Value="#FF99B6D1"/>
								</ColorAnimationUsingKeyFrames>
								<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlock">
									<EasingColorKeyFrame KeyTime="0" Value="White"/>
								</ColorAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="Pressed"/>
						<VisualState x:Name="Disabled"/>
					</VisualStateGroup>
				</VisualStateManager.VisualStateGroups>
				<Ellipse x:Name="ellipse" Fill="White" Stroke="#FF99B6D1" StrokeThickness="2"/>
				<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF99B6D1" FontWeight="Bold"><Run FontWeight="Normal" FontSize="16" FontFamily="Webdings" Text="Í"/></TextBlock>
			</Grid>
		</ControlTemplate>

	</UserControl.Resources>

	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="60" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<Grid>
			<Label Content="Commit" HorizontalAlignment="Left" Margin="12,28.04,0,6" Name="lblCommit" d:LayoutOverrides="Height" />
			<Label Content="Message" HorizontalAlignment="Left" Margin="12,5.38,0,0" Name="lblMessage" VerticalAlignment="Top" FontSize="14" FontWeight="Bold" />
			<Label Content="Author"  HorizontalAlignment="Right" Margin="0,0,16,0" Name="lblAuthor" VerticalAlignment="Bottom" FontSize="10"/>
			<Button Content="back to graphic view" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,20,0" Padding="10,0"
					Command="cmd:HistoryViewCommands.CloseCommitDetails"  Template="{DynamicResource BackButtonControlTemplate}" ToolTip="Back to graphic view" />
			<Button HorizontalAlignment="Right" Margin="0,15,79,0" x:Name="btnSwitch" Click="btnSwitch_Click" Template="{DynamicResource btnSwitchControlTemplate}" RenderTransformOrigin="-1.5,0.542" ToolTip="Reverse the comparison order" VerticalAlignment="Top"  />
			<Button HorizontalAlignment="Right" Margin="0,15,49,0" x:Name="btnSave" VerticalAlignment="Top" Click="btnSave_Click" Template="{DynamicResource PatchButtonTemplate}" RenderTransformOrigin="-1.5,0.542" ToolTip="Save patch ..."  />
			<Grid.Background>
				<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
					<GradientStop Color="#FFF2F2F2" Offset="0" />
					<GradientStop Color="#FFDBDBDB" Offset="1" />
					<GradientStop Color="#FFD8D5D5" Offset="0.331" />
				</LinearGradientBrush>
			</Grid.Background>
		</Grid>

		<Grid x:Name="detailsGrid" Grid.Row="1">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="300" MaxWidth="1000" MinWidth="20"/>
				<ColumnDefinition Width="4"/>
				<ColumnDefinition Width="3*"/>
				<ColumnDefinition Width="4"/>
				<ColumnDefinition Width="1*" MinWidth="20"/>                
			</Grid.ColumnDefinitions>

			<Grid>

				<Grid.RowDefinitions>
					<RowDefinition Height="36" />
					<RowDefinition Height="*" />
					<RowDefinition Height="4" />
					<!--<RowDefinition Height="36" />-->
					<RowDefinition Height="2*" />
				</Grid.RowDefinitions>

				<Grid Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Top" >
				<Grid.Background>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFCBCBCB" Offset="0" />
						<GradientStop Color="White" Offset="1" />
					</LinearGradientBrush>
				</Grid.Background>
				<RadioButton Content="Show Files" Height="16" HorizontalAlignment="Left" Margin="12,8,0,0" Name="radioShowFileTree" VerticalAlignment="Top" Checked="radioShowFileTree_Checked" />
				<RadioButton Content="Show Changes" Height="16" HorizontalAlignment="Left" Margin="120,8,0,0" Name="radioShowChanges" VerticalAlignment="Top" Checked="radioShowChanges_Checked" />
			</Grid>
						
				<TreeView Grid.Row="1" x:Name="fileTree" Margin="10,0,0,0" BorderBrush="{x:Null}" VerticalContentAlignment="Stretch" 
					  HorizontalAlignment="Stretch" SelectedItemChanged="fileTree_SelectedItemChanged">
				<TreeView.ItemTemplate>
					<HierarchicalDataTemplate ItemsSource="{Binding Children}"
											  DataType="{x:Type model:GitTreeObject}">

						<StackPanel Orientation="Horizontal" Height="18">
							<TextBlock Text="{Binding Name}" />
						</StackPanel>

					</HierarchicalDataTemplate>
				</TreeView.ItemTemplate>

				<TreeView.ItemContainerStyle>
					<Style TargetType="{x:Type TreeViewItem}">
						<Setter Property="IsExpanded"
								 Value="{Binding IsExpanded, Mode=TwoWay}" />
					</Style>
				</TreeView.ItemContainerStyle>

				<TreeView.ContextMenu>
					<ContextMenu>
						<MenuItem Header="Save File As ..." Name="menuSaveFile" Click="menuSaveFile_Click" />
					</ContextMenu>
				</TreeView.ContextMenu>
			</TreeView>

				<DataGrid Grid.Row="1" x:Name="patchList" Margin="10,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
					  GridLinesVisibility="None"  Foreground="#FF333333" Sorting="dataGrid1_Sorting" IsReadOnly="True" SelectedValuePath="Name"
					  SelectionMode="Single" Visibility="Collapsed" SelectionChanged="patchList_SelectionChanged" AutoGenerateColumns="False" 
					  CanUserResizeRows="False" CanUserDeleteRows="False" CanUserAddRows="False" CanUserReorderColumns="False" RowHeaderWidth="0">

				<DataGrid.Columns>
					<DataGridTextColumn Header="Status" Binding="{Binding ChangeType}" Width="80" />
					<DataGridTextColumn Header="File" Binding="{Binding Name}" Width="*" />
				</DataGrid.Columns>

			</DataGrid>

				<GridSplitter Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="4" ResizeDirection="Rows" />

				<Grid Grid.Row="3" Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Top" >
					<Grid.Background>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="#FFCBCBCB" Offset="0" />
							<GradientStop Color="White" Offset="1" />
						</LinearGradientBrush>
					</Grid.Background>
					<TextBlock Text="Commits of selected file" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="15,0,0,0" />
				</Grid>

				<ListBox Grid.Row="3" Margin="10,38,0,10" x:Name="lstFileCommits"
						 VerticalAlignment="Stretch" HorizontalAlignment="Stretch" SelectionChanged="lstFileCommits_SelectionChanged" />

			</Grid>
			
			<GridSplitter Grid.Column="1"
					  VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="4" ResizeDirection="Columns" />
			
			<Grid Grid.Column="2" Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Top" >
				<Grid.Background>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFCBCBCB" Offset="0" />
						<GradientStop Color="White" Offset="1" />
					</LinearGradientBrush>
				</Grid.Background>
				<TextBlock x:Name="txtFileName" Text="" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" />
				<CheckBox Content="Blame" Height="16" HorizontalAlignment="Right" Margin="0,10,20,0" Name="chkBlame" VerticalAlignment="Top" Click="chkBlame_Click" />
			</Grid>
			
			<Grid  Grid.Column="2" Background="White" Margin="0,38,0,10" HorizontalAlignment="Stretch">
				<!--<ContentControl x:Name="editor" />-->
				<avalonEdit:TextEditor Name="editor" FontFamily="Consolas" FontSize="10pt"/>
			</Grid>

			<GridSplitter Grid.Column="3"
						  VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="4" 
						  ResizeDirection="Columns" />

			<Grid Grid.Column="4">
				<Grid.RowDefinitions>
					<RowDefinition Height="36" />
					<RowDefinition Height="*" />
				</Grid.RowDefinitions>

				<Grid Height="36" HorizontalAlignment="Stretch" VerticalAlignment="Top" >
					<Grid.Background>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="#FFCBCBCB" Offset="0" />
							<GradientStop Color="White" Offset="1" />
						</LinearGradientBrush>
					</Grid.Background>
					<TextBlock Text="Message" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" />
				</Grid>
			
				<RichTextBox Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,10,0" 
						 Name="txtComments" IsReadOnly="True" 
						 VerticalScrollBarVisibility="Visible">
					<RichTextBox.Resources>
						<Style TargetType="{x:Type Paragraph}">
							<Setter Property="Margin" Value="0"/>
						</Style>
					</RichTextBox.Resources>
				</RichTextBox>

			</Grid>
			
		</Grid>
	</Grid>

</UserControl>
